package com.tgy.JUC.Single;

/***
 * @ClassName: Hungry
 * @Description: 饿汉单例模式
 * @Auther: 送你一块二向箔
 * @Date: 17:06 2022/3/15
 * @version : V1.0
 */

/**
 * 饿汉式单例模式，一加载就创建单例对象
 */
public class Hungry {

    //一上来就加载浪费空间
    private byte[] b1 = new byte[1024*1024];
    private byte[] b2 = new byte[1024*1024];
    private byte[] b3 = new byte[1024*1024];
    private byte[] b4 = new byte[1024*1024];

    private Hungry(){
    }
    private static final Hungry hungry = new Hungry();

    public static Hungry getInstance(){
        return hungry;
    }
}
